//
//  UIView+main.h
//  ClassMusic
//
//  Created by ChinaRainbow-iOS on 2018/2/7.
//  Copyright © 2018年 ChinaRainbow-iOS. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (main)

    //MARK: frame

- (float)ccx;
- (float)ccy;
- (float)ccwidth;
- (float)ccheight;

- (void)setccX:(float)x;
- (void)setccY:(float)y;
- (void)setccWidth:(float)w;
- (void)setccHeight:(float)h;

- (float)boundsWidth;
- (float)boundsHeight;
- (void)setBoundsWidth:(float)w;
- (void)setBoundsHeight:(float)h;


- (CGFloat)left;
- (CGFloat)top;
- (CGFloat)right;
- (CGFloat)bottom;
- (void)setTop:(CGFloat)top;
- (void)setRight:(CGFloat)right;
- (void)setBottom:(CGFloat)bottom;
- (void)setLeft:(CGFloat)left;
- (CGFloat)centerX;
- (void)setCenterX:(CGFloat)centerX;
- (CGFloat)centerY;
- (void)setCenterY:(CGFloat)centerY;
- (CGPoint)origin;
- (void)setOrigin:(CGPoint)origin;
- (CGSize)size;
- (void)setSize:(CGSize)size;
- (CGPoint)convertPoint:(CGPoint)point toViewOrWindow:(nullable UIView *)view;

    //MARK: function

    //垂直抖动
- (void)startVerticalShake;

    //水平抖动
- (void)startHorizontalShake;

    //添加动画遮罩 并在duration秒之后移除
- (void)addMaskViewWithDuration:(int)duration;

    //移除所有的子视图
- (void)removeAllSubview;

    //找到最近的UIViewController
- (UIViewController *_Nullable)nearestViewController;

- (UITableView *_Nullable)nearestTableView;

- (UIScrollView *_Nullable)nearestScrollView;

    //找到第一响应者
- (UIView *_Nullable)findFirstResponder;

    //标题View（是否loadingView）
+ (UIView *_Nullable)titileViewWithTitle:(NSString *_Nullable)title activity:(BOOL)activity;

    //标题View（带图片）
+ (UIView *_Nullable)titileViewWithTitle:(NSString *_Nullable)title image:(UIImage *_Nullable)image;

- (void)showShadow;


@property (nonatomic) IBInspectable CGFloat cornerRadius;

/** 头像圆角 */
@property (nonatomic) IBInspectable BOOL avatarCorner;

/** 边框 */
@property (nonatomic) IBInspectable CGFloat borderWidth;

/** 边框颜色*/
@property (nonatomic, strong) IBInspectable UIColor *borderColor;

+ (__kindof UIView *)MQLoadNibView;
- (void)MQSetViewCircleWithBorderWidth:(CGFloat) width andColor:(UIColor *)borColor;
- (void)MQViewSetCornerRadius:(CGFloat)radius;
@end
